#!/bin/sh
# Start/stop/restart X11

x11_start() {
  if [ -x /usr/X11R6/bin/fc-cache ]; then
    /usr/X11R6/bin/fc-cache -f &
  fi 
  if [ -x /usr/X11R6/bin/slim ]; then
    /usr/X11R6/bin/slim -d
  fi
}

x11_stop() {
  if [ -r /var/run/slim.lock ]; then
    PID=$(cat /var/run/slim.lock)
    kill $PID
  fi
}

x11_restart() {
  x11_stop
  sleep 1
  x11_start
}

case "$1" in
'start')
  x11_start
  ;;
'stop')
  x11_stop
  ;;
'restart')
  x11_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac

